-- Test if the check-box clcicked is currently selected…
if (item 1 of DialogValue(500,UserClic)) = 1 then
SetDialog 500,UserClic,0
else
SetDialog 500,UserClic,1
end if
else if UserClic is 18 then
if hidden is false then
ModifyItem 500,20,2
put true into Hidden
setDialog 500,18,"<< Show test item"
else
ModifyItem 500,20,1
put false into Hidden
setDialog 500,18,"<< Hide test item"
end if
else if UserClic is 19 then
if not Gray then
ModifyItem 500,20,3
put true into Gray
SetDialog 500,19,"<< Hilight test item"
else
ModifyItem 500,20,4
put false into Gray
SetDialog 500,19,"<< Unhilight test item"
end if
else if UserClic is 17 then
repeat with i is 1 to 100
SetDialog 500,13,i
end repeat
wait 30 ticks
SetDialog 500,13,0
else if UserClic is 16 then
if not Hy then
ModiFyItem 500,21,1
put true into Hy
SetDialog 500,16,"!!"
else
ModifyItem 500,21,2
put false into Hy
SetDialog 500,16,"?"
end if
end if
end repeat
if UserClic is 1 then Get_Result
DisDialog 500
end mouseUp
on Get_result
-- Now, take a look to the choices the user made
put false into Chk1
put false into Chk2
repeat with i is 5 to 9
if item 1 of DialogValue(500,i) is 1 then
put i into RadBtnChoosen
exit repeat
end if
end repeat
-- the checkboxes…
if item 1 of DialogValue(500,10) is 1 then put true into Chk1
if item 1 of dialogValue(500,11) is 1 then put true into Chk2
put item 1 of dialogValue(500,13) into CtrlVal
put RadBtnChoosen after line 4 of cd fld 2
put Chk1 after line 5 of cd fld 2
put Chk2 after line 6 of cd fld 2
put CtrlVal after line 7 of cd fld 2
show cd fld 2
end Get_result
-- part 3 (button)
-- low flags: 00
-- high flags: A002
-- rect: left=23 top=53 right=75 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Help Me !
----- HyperTalk script -----
on mouseUp
set lockscreen to true
if the visible of card field 1 is false then
show card field 1
set the name of the target to "Hide it!"
repeat with i is 3 to 10
show card button i
end repeat
else
hide card field 1
set the scroll of card field 1 to 0
set the name of the target to "Help Me !"
repeat with i is 3 to 10
hide card button i
end repeat
end if
end mouseUp
-- part 4 (button)
-- low flags: 80
-- high flags: A004
-- rect: left=23 top=109 right=131 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: ModDialog
----- HyperTalk script -----
on mouseUp
set the scroll of card field 1 to 549
end mouseUp
-- part 5 (button)
-- low flags: 80
-- high flags: A004
-- rect: left=23 top=155 right=177 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: DisDialog
----- HyperTalk script -----
on mouseUp
set the scroll of card field 1 to 1770
end mouseUp
-- part 6 (button)
-- low flags: 80
-- high flags: A004
-- rect: left=23 top=132 right=154 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: HandleDialog
----- HyperTalk script -----
on mouseUp
set the scroll of card field 1 to 1405
end mouseUp
-- part 7 (button)
-- low flags: 80
-- high flags: A004
-- rect: left=23 top=201 right=223 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: SetDialog
----- HyperTalk script -----
on mouseUp
set the scroll of card field 1 to 2382
end mouseUp
-- part 8 (button)
-- low flags: 80
-- high flags: A004
-- rect: left=23 top=178 right=200 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: DialogValue
----- HyperTalk script -----
on mouseUp
set the scroll of card field 1 to 1926
end MouseUp
-- part 9 (button)
-- low flags: 80
-- high flags: A004
-- rect: left=23 top=224 right=246 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: ParamDialog
----- HyperTalk script -----
on mouseUp
set the scroll of card field 1 to 2754
end MouseUp
-- part 27 (button)
-- low flags: 80
-- high flags: A004
-- rect: left=23 top=270 right=292 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Skeleton╔
----- HyperTalk script -----
on mouseUp
set the scroll of card field 1 to 3536
end MouseUp
-- part 32 (button)
-- low flags: 80
-- high flags: A004
-- rect: left=23 top=247 right=269 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: ModifyItem
----- HyperTalk script -----
on mouseUp
set the scroll of card field 1 to 3248
end MouseUp
-- part 36 (button)
-- low flags: 00
-- high flags: A002
-- rect: left=23 top=80 right=102 bottom=123
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: About╔
----- HyperTalk script -----
on mouseUp
if the visible of cd fld 1 is true then
set the scroll of cd fld 1 to 0
exit to hypercard
end if
ModDialog 505,Geneva,9,H
if the result is not empty then exit to hypercard
repeat
get HandleDialog(505)
if it is 1 then exit repeat
end repeat
DisDialog 505
end mouseUp
-- part 52 (field)
-- low flags: 81
-- high flags: 0004
-- rect: left=54 top=160 right=270 bottom=491
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: resultat
----- HyperTalk script -----
on MouseUp
hide me
put empty into last word of line 4 of me
put empty into last word of line 5 of me
put empty into last word of line 6 of me
put empty into last word of line 7 of me
end MouseUp
-- part contents for card part 1
----- text -----
These externals are © 89, Antoine Latour. They are free, and your are allowed to distribute them in public domain products, if the line : "Externals ModDialog, DisDialog, HandleDialog, SetDialog, DialogValue & ParamDialog are © 89, Antoine Latour" appears clearly in your stacks. For any commercial products, please contact me at the following adress :
Antoine Latour, 11, rue du Mai 1945, 91150 Etampes, France.
In order to use dialogs in Hypercard stacks, i've implemented larges parts of the dialog manager in these six externals :
ΓÇó ModDialog, which bring up a dialog window on the screen;
ΓÇó DisDialog, which dispose it;
ΓÇó HandleDialog, which return you the item choosen by the user;
ΓÇó DialogValue, which return the value or the state of an item of the dialog item list;
ΓÇó SetDialog, which allow you to change the state or the value of an item of the dialog item list;
ΓÇó ParamDialog, which allow you to change the text displayed by a dialog.
ΓÇó ModifyItem, which allow you to change the face of an item of the ditl list.
To use these commands, you need a good knowledge of the dialog manager of the Macintosh. See Inside Macintosh Vol I and III.
The first thing you've to do is to design your dialog. You can use ResEdit, Rmaker or other software to create them. If you use ResEdit, create a new file, then create a new DLOG resource. Warning : the visible attribute may be set to FALSE, RefCon may be set to 0. All other attributes, in particular GoAwayFlag, may be set to false.
Once your dialog is designed, with it's item list, you've to note carrefully : the ID number of the DLOG, and the item number of all of the items. Usually, item 1 may be the OK button of the dialog.
Then, you've to past the DLOG, the DITL, and all other associated resources ( PICT, ICON, etc.. ) into your stack.
The ModDialog XCMD display a dialog on the screen, with a variety of options, depending of the parameter specifieds.
The simpliest way to call ModDialog is :
ModDialog [ID]
where ID is the dialog resource number. In this case, ModDialog display the dialog centered on the hyperCard screen.
You can also add a second parameter, the H letter, like this :
ModDialog [ID],H
In this case, ModDialog display the dialog centered on the screen, and draw a round-rect around the first item of the dialog item list. It is usefull to show the user that typing Enter ou Return is equivalent to click in this item. In general, the first item is a button, Ok or Cancel.
You can also ask ModDialog to put the dialog at a particular location on the screen. To do that, type :
ModDialog [ID],[left],[top]
where left and top are two integers relatives to the card, where the topLeft corner of the dialog will take place.
In addition, you can ask ModDialog to put the dialog where you want, and to draw the round-rect around item #1:
ModDialog [ID],[left,[top],H
ModDialog allows you to set the font and size of the static or editable text of the DITL. For that, you've to specify the name of the font you want to use, and its size :
ModDialog [ID],[font],[size]
In this case, the dialog will be centered on the screen. You can also ask, in addition, to have the first item hilited :
ModDialog [ID],[font],[size],H
At least, you can also ask ModDialog to display the dialog wherever you want on the screen, with the first item hilited and a specific font and size used :
ModDialog [ID],[left],[top],H,[font],[size]
Attention : the order of the specified parameter is important. All other order for them will cause the display of an error message : 'bad parameter'.
When you use ModDialog, anyway, some errors messages may occurs. First, if the specified dialog can't be found, ModDialog will notice you 'resource not found'. If the specified dialog still exist, ModDialog answer 'this dialog still exist'.
If all goes right, the result will be empty. You've not to store any pointer in any global. The only way to specify of what dialog you're speaking is the ID number of the dialog. Once the dialog displayed, you'll be use this ID to call others Xcmd of this set. I recommend to
store this ID in a global variable, like in the following examples.
HandleDialog is a function that return the item number choosen by the user. Its a one-event function. In most cases, you must call HandleDialog along a repeat loop, and you will exit this loop when the 'OK' or 'Cancel' button will be choose. HandleDialog return an integer, between 1 and 64 ( the maximum number of items in a DITL ).
Example :
on Test_Dialog
global MyDlogID
repeat
put HandleDialog(MyDlogID) into UserAnswer
if UserAnswer is 1 then -- OK Button
exit repeat
else if UserAnswer is 2 then -- Cancel button
exit to HyperCard
end if
end repeat
-- here is the script wich look for the value of
-- differents items. After that, you have to use
-- DisDialog to put away the dialog
end Test_Dialog
NOTE : Only enabled items can be seen by ModDialog. See your DITL with resEdit to Enable ou disable your item.
Giving a Id of a previously displayed dialog, and an item number of the item list, DialogValue return you the value, or the state of this item, depending of what kind of item you're speaking about, and the type of this item.
If the item is a check-box, a radio-button or a control item ( scroll bar, etc..) dialogValue will return you its value ( O or 1 for radio-buttons and check-boxes, 0..255 for others ); If the item is a button, a staticText, or an editable text, dialogValue will return you the title or the content of this control. In all cases, DialogValue will return you a second value, separated from the first by a comma, which give you the type of the control, as follow : 'BtnItem' ( buttons ) , 'ChkItem' ( check-boxes ), 'RadBtn' ( radio-buttons ), 'EditText' ( editable text ), 'StaticText' (static text ), 'IconItem' ( icons ), 'PicItem' (pictures) 'CntrlItem' ( others controls ) or 'Unknown'.
Example :
On What_Value
global MyDlogID
put DialogValue (MyDlogID,1) into ValueOfFirstItem
put DialogValue (MyDlogID,2) into ValueOfSecondItem
Given a ID of a dialog, and an item number of the item list, SetDialog will set a value or a state to the item, depending of what king of item you're speaking about. If the <Item> is a check-box or a radio-button, SetDialog will set the item to highlighed or not. In this case, you will use 1 or 0 in the third parameter, with 1 to highligh to item. If the <item> is a control item, you can pass values between 0 and 255. If the <item> is a static-text, editable-text, or a button, SetDialog will set the test of this item to [value], which is a sample string. Only first 255 caracters will be used.
Examples :
On Set_Item
-- set a checkbox ( item 3 of the DITL ) to on
global MyDlogID
SetDialog MyDlogID,3,1
end Set_Item
on Set_Item
-- set a static-text ( item 3 of the DITL ) to a string
ParamDialog provides a means of substituting text in statText items: Text1 through Text3 will replace the special strings '^0' through '^3' in all statText items in subsequent dialog, notified in the <pointer> parameter. Pass empty strings for parameters not used.
NOTE : you must specify the four text parameter, empty or not; If you want to change only one of the four lines, you must pass the full four line as parameter :
ATTENTION : In this version, any call to ParamDialog on a dialog using a specific font and size will transform this fonte into Chicago 12, the system font. For any dialog that could be changed by a call to ParamDialog or SetDialog ( see above ), i do not recommend to use a font and size specification during the modDialog call.
Given a ID on a previously displayed dialog, ModifyItem allow to to hide or show any item of the ditl, and to make any button or text gray-dimmed or back to black.
For this four function, you've to spedify the dlog considered, the number of the items you want to modify, and the state you want for it, like this :
ModifyItem [ID],[item],[state]
Where that is an integer beetwen 1 and 4 ( all others values are rejected ).
1 make the control visible, 2 make the control unvisible, 3 make the control gray-dimmed and non selectable, 4 make the control black and selectable.
You can mix all of this values in succesives calls to ModifyItem. You can, for instance, ask ModifyItem to make your control gray-dimmed after have ask hil to make your control invisible. Once you've call it to make your control visible, it'll appears in gray.
ΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó A script Skeleton ΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó
During the repeat ... HandleDialog ... end repeat loop, user may click in check-boxes or radio-button. If there is more of 2 radio-button in a group, you must switch off all radio-buttons first, then highligh the radio-button the user choose. I recommend to use this kind of script :
On Display_Dialog
global MyId
put 500 into MyID
-- Display the dialog first
ModDialog MyID
-- In this dlog, there is two distincts group of
-- radio- button, and a group of 2 check-boxes. Only
-- one of radio-button of each group must be --
-- highligh. We create two series of radio-button :
-- item number of the radio-btn of first group :
put "3,4,5" into RadButtons1
-- item numbers of the radio-btn of second group :
put "6,7,8" into RadButtons2
-- item numbers of the two check-boxes :
put "9,10" into CheckBoxes
-- repeat loop
repeat
put HandleDialog(MyID) into userClic
if userClic is in RadButtons1 then
-- user clic in first group of radio-buttons
-- first, switch off all these radio-buttons :
repeat with i is 3 to 5
SetDialog MyID,i,0
end repeat
-- then we highligh the radio-button choosen
SetDialog MyID,UserClic,1
end if
if userClic is in RadButtons2 then
-- user clic in second group of radio-buttons
-- first, switch off all these radio-buttons :
repeat with i is 6 to 8
SetDialog MyID,i,0
end repeat
-- then we highligh the radio-button choosen
SetDialog MyID,UserClic,1
end if
if userClic is in CheckBoxes
-- user clic in a check-boxe. Is it actually
-- highligh or not ?
if DialogValue(MyID,UserClic) is O then
-- not hilight, so we select it
SetDialog MyID,UserClic,1
else
-- if it's highlighed, we switch it off
SetDialog MyID,UserClic,0
end if
end if
if userClic is 1 then exit repeat -- ok button
end repeat
-- Here is the script wich allow us to see what's button a
-- selected :
repeat with i is 3 to 5
if DialogValue(MyID,i) is 1 then
put i into FirstGroupChoice
end if
end repeat
repeat with i is 6 to 8
if DialogValue(MyID,i) is 1 then
put i into SecondGroupChoice
end if
end repeat
-- Now, the item number of each radio-button group
-- currently selected are stored in the variables
-- 'firstGroupChoice' and 'SecondGroupChoice'
-- Look for the checkBoxes
if DialogValue(MyID,9) is 1 then put true into ¬
FirstBox
if dialogValue(MyID,10) is 1 the put true into ¬
SecondBox
-- Now, we dispose the dialog :
DisDialog MyID
end Display_dialog
See the script of card button 'Let's try' of this stack for more infos.
I apologize for my 'non-fluent' english. But why don't you speak french as everybody does ?